<template>
  <a-card class="general-card">
    <template #title>
         <span class="title-block-item"></span>
         <span>近3天进件数据统计</span>
      </template>
    <Chart height="305px" :option="chartOption" />
  </a-card>
</template>

<script lang="ts" setup>
  import useChartOption from '@/hooks/chart-option';
  
  let props = defineProps({
      yAxisData: {
        type: Array,
        default: ()=> []
      },
      seriesData:{
        type: Array,
        default: ()=> []
      }
  });

  const { chartOption } = useChartOption((isDark) => {
    isDark = false; //冲掉之前的设置
    return {
      grid: {
        left: 80,
        right: 20,
        top: 0,
        bottom: 20,
      },
      xAxis: {
        type: 'value',
        axisLabel: {
          show: true,
          formatter(value: number, idx: number) {
            return value;
            /// 数值转换
            // if (idx === 0) return String(value);
            // return `${Number(value) / 1000}k`;
          },
        },
        splitLine: {
          lineStyle: {
            color: isDark ? '#484849' : '#E5E8EF',
          },
        },
      },
      yAxis: {
        type: 'category',
        data: props?.yAxisData,
        axisLabel: {
          show: true,
          color: '#4E5969',
        },
        axisTick: {
          show: true,
          length: 2,
          lineStyle: {
            color: '#A9AEB8',
          },
          alignWithLabel: true,
        },
        axisLine: {
          lineStyle: {
            color: isDark ? '#484849' : '#A9AEB8',
          },
        },
      },
      tooltip: {
        show: true,
        trigger: 'axis',
      },
      series: [
        {
          data: props?.seriesData,
          type: 'bar',
          barWidth: 16,
          label: {
            // show: true, // 显示数值
            // position: 'top' // 数值显示的位置
          },
          itemStyle: {
            color: '#409EFF',
            borderRadius: 0,
          },
        },
      ],
    };
  });
</script>

<style scoped lang="less"></style>
